home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Apps / Utilities / Unix / CommandMon / Controller.m < prev    next >
Text File  |  1992-12-26  |  1KB  |  79 lines

  1.  
  2. #import "Controller.h"
  3. #import "UNIXobject.h"
  4. #import "Indicator.h"
  5. #import <strings.h>
  6. #import <streams/streams.h>
  7. #import <appkit/Text.h>
  8. #import <appkit/TextField.h>
  9. #import <appkit/ScrollView.h>
  10. #import <appkit/Application.h>
  11. #import <appkit/Window.h>
  12.  
  13. @implementation Controller
  14.  
  15. - appDidInit:sender
  16. {
  17.     time=10;
  18.     strcpy(command,"");
  19.     [unixObject setDelegate:self];
  20.     [commandField selectText:self];
  21.     [self setInterval];
  22.     return self;
  23. }
  24.  
  25. - setCommand:sender
  26. {
  27.     strcpy(command,[sender stringValue]);
  28.     [commandField selectText:self];
  29.     [self doCommand];
  30.     return self;
  31. }
  32.  
  33. - setTime:sender
  34. {
  35.     time=[sender floatValue];
  36.     [commandField selectText:self];
  37.     [self setInterval];
  38.     return self;
  39. }
  40.  
  41. - (void)doCommand
  42. {
  43.     if (strcmp(command,"")) {
  44.         [theIndicator flash];
  45.         [unixObject execute:command];
  46.     }
  47.     return;
  48. }
  49.  
  50. - returnOutput:(NXStream *)theStream
  51. {
  52.     [[outputText docView] readText:theStream];
  53.     return self;
  54. }
  55.  
  56. void repeat (DPSTimedEntry timedEntry, double timeNow, void *data)
  57. {
  58.     [(id)data doCommand];
  59. }
  60.  
  61.  
  62. - setInterval
  63. {
  64.        void repeat ();
  65.     if (timer) DPSRemoveTimedEntry(timer);
  66.     timer=DPSAddTimedEntry(time,&repeat,self,NX_BASETHRESHOLD);
  67.     return self;
  68. }
  69.  
  70. - windowWillResize:sender toSize:(NXSize *)size
  71. {
  72.     if (size->width < 348)
  73.         size->width=348;
  74.     if (size->height < 166)
  75.         size->height=166;
  76.     return self;
  77. }
  78. @end
  79.